const DB = require('../tools/mysql')

module.exports = async ctx => {

  const { id, type } = ctx.request.body

  let table = ''
  switch (type) {
    case '0':
      table = 'village_registry'
      break
    case '1':
      table = 'home_registy'
      break
    case '2':
      table = 'three_implementation'
      break
    case '3':
      table = 'issue_list'
      break
    default:
      table = 'village_registry'
  }

  const [data] = await DB(table).select(`${table}.*`, 'user.name as inspectorname').leftJoin('user', `${table}.inspector`, 'user.id').where(`${table}.id`, id)

  ctx.body = { code: 1, msg: '查询成功', data }

}